import { baseUrlApi, requestClient, type Result } from '#/api/request';

/** 获取友情链接列表 */
export const getLinks = (params?: object) => {
  return requestClient.get<Result>(baseUrlApi('/portal/admin/social'), { params });
};

/** 添加友情链接 */
export const postLinks = (data?: object) => {
  return requestClient.post<Result>(baseUrlApi('/portal/admin/social'), data);
};

/** 获取友情链接信息 */
export const getLinkInfo = (data: { id: number }) => {
  return requestClient.get<Result>(baseUrlApi(`/portal/admin/social/${data.id}`));
};

/** 编辑友情链接 */
export const putLink = (data?: any) => {
  return requestClient.put<Result>(baseUrlApi(`/portal/admin/social/${data.id}`), data);
};

/** 删除友情链接 */
export const deleteLink = (data?: any) => {
  return requestClient.delete<Result>(baseUrlApi(`/portal/admin/social/${data.id}`));
};

/** 设置友情链接显示状态 */
export const postLinkStatus = (data: { id: number; status: number }) => {
  return requestClient.post<Result>(
    baseUrlApi(`/portal/admin/social/${data.id}/status/${data.status}`),
    data,
  );
};

/** 批量设置友情链接显示状态 */
export const postLinksStatus = (data: { ids: Array<any>; status: number }) => {
  return requestClient.post<Result>(
    baseUrlApi(`/portal/admin/social/status/${data.status}`),
    data,
  );
};

/** 友情链接排序 */
export const postLinksOrders = (data: {
  list_orders: { [key: string]: number };
}) => {
  return requestClient.post<Result>(
    baseUrlApi(`/portal/admin/social/list/order`),
    data,
  );
};
